package org.wheel.plugins.toolkit.sql.helper;

import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import org.wheel.module.core.enm.NormalExceptionEnum;
import org.wheel.module.core.exception.NormalException;

public class JSqlParseUtil {

    public static Expression convertToExpression(String condition) {
        try {
            return CCJSqlParserUtil.parseCondExpression(condition);
        } catch (JSQLParserException e) {
            throw new NormalException(NormalExceptionEnum.OPERATE_FAIL.getCode(), "SQL拼接过程中where条件转换失败：" + condition);
        }
    }
}
